Refactor backend into own package