autopath normalisation

Usa of autopath is sensible only for executables and
only when they are executed!
This commit does on of three options:
a) class/function definition only -> no autopath (few cases)
b) def main present but autopath import on top of module ->
importing autopath in main function instead (most cases)
c) if __name__=='__main__' clause missing  ->
introducing ifmain clause and moving import autopath
only under ifmain clause (few cases)
Similar reasons as autopath:
- argparse is used only when the module is used as executable is not needed when the class or function definition are used
(I may revert this if you do not like it)