A lot of refactoring, adapting to work in 1.3, and UI fixes