Implemented 3 modes and some cleanup