Tried to change code structure to facilitate login page. Not finished yet.