Compilation fixes and minor refactor.