Fix overflow problems