Big code refactoring of the definition module to be more future proof and readable