Refactor, fixes and completed features