Fixed building and some cleanup. Added building tests.