fixed lots of code review comments. still lots left, though.