Bugfixes, implement permissive mode & logging
remove extraneous debugging printf