Needs work; memory-leaks, function splitting, etc.