Fix problems with casting Integer to Long