Added rectangle fit functionality.