Push all code into a class, no real change except that and a few functions renaming. Not yet ready for production.