Cleanup and make it npm packageable