Casting to remove a compiler warning about Int being too big and some minor improvements