Cleaned up source, removing unused functions