Fixed bugs found by Cython + removed unnecessary scope checks in plugins