Cleaned up initialization function. Added more functions.