Fixes for python3 and code cleanup
Code clean up and fixes due to new crypto_engine