cleaner, better commenting, fixed some things, still broken