Codereview

Changes implemented, merge with master.