Login fix, code cleanup and standardisation