BIG CLEANUP
separating scripts from lib code