Tested most functions and fixed bugs.