Probably unstable - attempted to modularise client js code