Thanks for the patch. I went through it and tried to simplify it where possible. - removed unused module imports - merged some procedures - wrote an abstraction for submodules - changed comment style where necessary All proposed changes relative to your patch can be seen here: