Major refactor of class library