major refactoring to comply with conventions