Refactor loopback backend