add separate class for dynomodule, add some optimizations and fixes