Refactor this to remove locomotive as it wasn't useful
refactor a load of stuff, add some cool error handling, fix middleware