Add crap ton of comments, some minor optimizations