Fix bugs, inversion should work correctly now