Fixed rectangle creation tool. Misc code clean-up.