Lots of changes

Translated bunch of code.