Get rid of module level code execution and some small fixes.

* `delete` function was fixed
(missed parameter was added)
* code style fixes in modified functions

reviewers: @uvizhe, @tIGO