Bug fixes to get it to build