Bug fixes - out of range exceptions and incorrect division are fixed