[#3] Bug fixes and hardening