Cleaned up code, removed superfluous functions.