Fixed issues

There were a number of compiler errors/warnings in VS. Added functions.h
for declarations and wrapped headers in ifndefs.