rewrite implicit casts to new concrete cast functions
added toLong cast function