More build fixing, refactoring and experimenting.