Fix multiple errors and refactor attributes