restructured code; engine object with private parts in closures; adjusted calls in main.js and testing.js