Misc fixes

Fix some problems as I tried out HaLVM.

To be honest the fixes to build system is only bandaid for minor problems. If anyone is planning to overhaul it that would be great. :-)