Move main program code to lib directory (main.nnd)