reformat & restructure the worst parts of account.js