Big Update

Important code refactoring for better manteinance