Cleaned up the code, deleted unused functions.