Setting up API for handling extension modules, fixing some issues with #9, #13, #16 and #17