Code cleanup and some refactoring, fixed transform points