diff --git a/settings/css/settings.css b/settings/css/settings.css
index bec8534aa4818b168835f8ac2f788761dd0e9a90..906712a56ba8b1bb0300535ad303ed1346faad12 100644
--- a/settings/css/settings.css
+++ b/settings/css/settings.css
@@ -166,9 +166,14 @@ span.securitywarning, span.connectionwarning {
 	color:#C33;
 	font-weight:bold;
 }
-table.shareAPI td { padding-bottom: 0.8em; }
-table.shareAPI input#shareapiExpireAfterNDays {width: 25px;}
-table.shareAPI .indent { padding-left: 2em; }
+#shareAPI p { padding-bottom: 0.8em; }
+#shareAPI input#shareapiExpireAfterNDays {width: 25px;}
+#shareAPI .indent {
+	padding-left: 28px;
+}
+#shareAPI .double-indent {
+	padding-left: 56px;
+}
 
 #mail_settings p label:first-child {
 	display: inline-block;
diff --git a/settings/js/admin.js b/settings/js/admin.js
index bc95c6a3dc52d2e058d6ec025ff48bb849d9c8f3..7036f6dbf2a336fd02a414715411a7b17de12ae9 100644
--- a/settings/js/admin.js
+++ b/settings/js/admin.js
@@ -60,7 +60,7 @@ $(document).ready(function(){
 	});
 
 	$('#shareAPIEnabled').change(function() {
-		$('.shareAPI td:not(#enable)').toggle();
+		$('#shareAPI p:not(#enable)').toggleClass('hidden', !this.checked);
 	});
 
 	$('#shareAPI input').change(function() {
@@ -82,6 +82,7 @@ $(document).ready(function(){
 
 	$('#allowLinks').change(function() {
 		$("#publicLinkSettings").toggleClass('hidden', !this.checked);
+		$('#setDefaultExpireDate').toggleClass('hidden', !(this.checked && $('#shareapiDefaultExpireDate')[0].checked));
 	});
 
 	$('#security').change(function(){
diff --git a/settings/templates/admin.php b/settings/templates/admin.php
index e1348916b69828bcd54e77783f7badc30d58af41..1d75624d8c0462d39f11e6c1c6170140ad55338a 100644
--- a/settings/templates/admin.php
+++ b/settings/templates/admin.php
@@ -232,20 +232,18 @@ if (!$_['internetconnectionworking']) {
 
 <div class="section" id="shareAPI">
 	<h2><?php p($l->t('Sharing'));?></h2>
-	<table class="shareAPI">
-		<tr>
-			<td id="enable">
-				<input type="checkbox" name="shareapi_enabled" id="shareAPIEnabled"
-					   value="1" <?php if ($_['shareAPIEnabled'] === 'yes') print_unescaped('checked="checked"'); ?> />
-				<label for="shareAPIEnabled"><?php p($l->t('Allow apps to use the Share API'));?></label><br/>
-			</td>
-		</tr>
-		<tr>
-			<td <?php if ($_['shareAPIEnabled'] === 'no') print_unescaped('class="hidden"');?>>
-				<input type="checkbox" name="shareapi_allow_links" id="allowLinks"
-					   value="1" <?php if ($_['allowLinks'] === 'yes') print_unescaped('checked="checked"'); ?> />
-				<label for="allowLinks"><?php p($l->t('Allow users to share via link'));?></label><br/>
-				<div <?php ($_['allowLinks'] === 'yes') ? print_unescaped('class="indent"') : print_unescaped('class="hidden indent"');?> id="publicLinkSettings">
+		<p id="enable">
+			<input type="checkbox" name="shareapi_enabled" id="shareAPIEnabled"
+				   value="1" <?php if ($_['shareAPIEnabled'] === 'yes') print_unescaped('checked="checked"'); ?> />
+			<label for="shareAPIEnabled"><?php p($l->t('Allow apps to use the Share API'));?></label><br/>
+		</p>
+		<p class="<?php if ($_['shareAPIEnabled'] === 'no') p('hidden');?>">
+			<input type="checkbox" name="shareapi_allow_links" id="allowLinks"
+				   value="1" <?php if ($_['allowLinks'] === 'yes') print_unescaped('checked="checked"'); ?> />
+			<label for="allowLinks"><?php p($l->t('Allow users to share via link'));?></label><br/>
+		</p>
+
+			<p id="publicLinkSettings" class="indent <?php if ($_['allowLinks'] !== 'yes' || $_['shareAPIEnabled'] === 'no') p('hidden'); ?>">
 				<input type="checkbox" name="shareapi_enforce_links_password" id="enforceLinkPassword"
 						   value="1" <?php if ($_['enforceLinkPassword']) print_unescaped('checked="checked"'); ?> />
 				<label for="enforceLinkPassword"><?php p($l->t('Enforce password protection'));?></label><br/>
@@ -256,46 +254,38 @@ if (!$_['internetconnectionworking']) {
 				<input type="checkbox" name="shareapi_default_expire_date" id="shareapiDefaultExpireDate"
 				       value="1" <?php if ($_['shareDefaultExpireDateSet'] === 'yes') print_unescaped('checked="checked"'); ?> />
 				<label for="shareapiDefaultExpireDate"><?php p($l->t('Set default expiration date'));?></label><br/>
-				<div id="setDefaultExpireDate" <?php ($_['shareDefaultExpireDateSet'] === 'no') ? print_unescaped('class="hidden indent"') : print_unescaped('class="indent"');?>>
+
+			</p>
+				<p id="setDefaultExpireDate" class="double-indent <?php if ($_['allowLinks'] !== 'yes' || $_['shareDefaultExpireDateSet'] === 'no' || $_['shareAPIEnabled'] === 'no') p('hidden');?>">
 					<?php p($l->t( 'Expire after ' )); ?>
 					<input type="text" name='shareapi_expire_after_n_days' id="shareapiExpireAfterNDays" placeholder="<?php p('7')?>"
 						   value='<?php p($_['shareExpireAfterNDays']) ?>' />
 					<?php p($l->t( 'days' )); ?>
 					<input type="checkbox" name="shareapi_enforce_expire_date" id="shareapiEnforceExpireDate"
-						   value="1" <?php if ($_['shareEnforceExpireDate'] == 'yes') print_unescaped('checked="checked"'); ?> />
+						   value="1" <?php if ($_['shareEnforceExpireDate'] === 'yes') print_unescaped('checked="checked"'); ?> />
 					<label for="shareapiEnforceExpireDate"><?php p($l->t('Enforce expiration date'));?></label><br/>
-				</div>
-
-				</div>
-			</td>
-		</tr>
-		<tr>
-			<td <?php if ($_['shareAPIEnabled'] === 'no') print_unescaped('class="hidden"');?>>
-				<input type="checkbox" name="shareapi_allow_resharing" id="allowResharing"
-					   value="1" <?php if ($_['allowResharing'] === 'yes') print_unescaped('checked="checked"'); ?> />
-				<label for="allowResharing"><?php p($l->t('Allow resharing'));?></label><br/>
-			</td>
-		</tr>
-		<tr>
-			<td <?php if ($_['shareAPIEnabled'] === 'no') print_unescaped('class="hidden"');?>>
-				<input type="checkbox" name="shareapi_only_share_with_group_members" id="onlyShareWithGroupMembers"
-					   value="1" <?php if ($_['onlyShareWithGroupMembers']) print_unescaped('checked="checked"'); ?> />
-				<label for="onlyShareWithGroupMembers"><?php p($l->t('Restrict users to only share with users in their groups'));?></label><br/>
-			</td>
-		</tr>
-		<tr>
-			<td <?php if ($_['shareAPIEnabled'] === 'no') print_unescaped('class="hidden"');?>>
-				<input type="checkbox" name="shareapi_allow_mail_notification" id="allowMailNotification"
-					   value="1" <?php if ($_['allowMailNotification'] === 'yes') print_unescaped('checked="checked"'); ?> />
-				<label for="allowMailNotification"><?php p($l->t('Allow users to send mail notification for shared files'));?></label><br/>
-			</td>
-		</tr>
-		<tr>
-			<td <?php if ($_['shareAPIEnabled'] === 'no') print_unescaped('class="hidden"');?>>
-				<input type="checkbox" name="shareapi_exclude_groups" id="shareapiExcludeGroups"
-				       value="1" <?php if ($_['shareExcludeGroups']) print_unescaped('checked="checked"'); ?> />
-				<label for="shareapiExcludeGroups"><?php p($l->t('Exclude groups from sharing'));?></label><br/>
-				<div id="selectExcludedGroups" class="<?php ($_['shareExcludeGroups']) ? p('indent') : p('hidden indent'); ?>">
+				</p>
+		<p class="<?php if ($_['shareAPIEnabled'] === 'no') p('hidden');?>">
+			<input type="checkbox" name="shareapi_allow_resharing" id="allowResharing"
+				   value="1" <?php if ($_['allowResharing'] === 'yes') print_unescaped('checked="checked"'); ?> />
+			<label for="allowResharing"><?php p($l->t('Allow resharing'));?></label><br/>
+		</p>
+		<p class="<?php if ($_['shareAPIEnabled'] === 'no') p('hidden');?>">
+			<input type="checkbox" name="shareapi_only_share_with_group_members" id="onlyShareWithGroupMembers"
+				   value="1" <?php if ($_['onlyShareWithGroupMembers']) print_unescaped('checked="checked"'); ?> />
+			<label for="onlyShareWithGroupMembers"><?php p($l->t('Restrict users to only share with users in their groups'));?></label><br/>
+		</p>
+		<p class="<?php if ($_['shareAPIEnabled'] === 'no') p('hidden');?>">
+			<input type="checkbox" name="shareapi_allow_mail_notification" id="allowMailNotification"
+				   value="1" <?php if ($_['allowMailNotification'] === 'yes') print_unescaped('checked="checked"'); ?> />
+			<label for="allowMailNotification"><?php p($l->t('Allow users to send mail notification for shared files'));?></label><br/>
+		</p>
+		<p class="<?php if ($_['shareAPIEnabled'] === 'no') p('hidden');?>">
+			<input type="checkbox" name="shareapi_exclude_groups" id="shareapiExcludeGroups"
+			       value="1" <?php if ($_['shareExcludeGroups']) print_unescaped('checked="checked"'); ?> />
+			<label for="shareapiExcludeGroups"><?php p($l->t('Exclude groups from sharing'));?></label><br/>
+		</p>
+			<p id="selectExcludedGroups" class="indent <?php if (!$_['shareExcludeGroups'] || $_['shareAPIEnabled'] === 'no') p('hidden'); ?>">
 				<select
 					class="groupsselect"
 					id="excludedGroups" data-placeholder="groups"
@@ -306,10 +296,7 @@ if (!$_['internetconnectionworking']) {
 				</select>
 				<br />
 				<em><?php p($l->t('These groups will still be able to receive shares, but not to initiate them.')); ?></em>
-				</div>
-			</td>
-		</tr>
-	</table>
+			</p>
 </div>
 
 <div class="section" id="security">