Fixed an int division bug and also a local object lifetime bug.