Main application cleaned up, some further apis fleshed out and fixed up.