Various bug fixes and improvements.
Merge remote-tracking branch 'origin/Semi-final' into Semi-final

Conflicts:
	main/html/profile.php
Merge remote-tracking branch 'origin/Semi-final' into Semi-final