Bolt.js modularisation and cleanup

Work in progress...