Fix bugs revealed in real-world testing