fixed build; merging into master (still needs debugging)