Added define guards, started database I/O