Fix some issues from review, make it compile on gcc 4.6 and linux