completely reengineered the backend for maximum robustness