Backend architecture and code fixes