Build and publish working. Lots of refactoring.