fixing bugs from this afternoon. Rebuilding
Added some comments, cleaned up. Hopefully no new bugs