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)
No, I did not test it in all cases.