Initial commit, with some cleanup and fixes.