Added support for enabling/disabling encryption on input/output and cleaned code