Major restucture and cleanup

Changed several things, as described in the single commits