Refactoring of init.py. Moved functionality into separate modules. Some minor fixes to make unit test work under 'standard asap'.