Major refactoring and compliance code

see changelog for details