Helpfunctions adjusted
better structured, redundant variables deleted, clean up