codechanges for easier handling

first part of rewriting whole code, making it easier to manage and more
intuitive