fixed bugs with modes, will need cleaning up