Added more unit functionality and refactored more code.