Java port update + minor type cast fixes