Compile fixes, and some fixed functionality