Major refactoring of code, annotation of everything