Re-wrote reversebinary in python.