Ensure that buffer is always passed integer values.
Fixed integer math problem.