more npm-ish

moved cgi and server into a 'lib' folder
Relocated extensions
Small bug fixes left from conversion
Tiny fixes
Slight formatting