Rewrote and cleaned up everything! Still needs fixes.