Internal structure defined, code cleanup/refactor