Fix some tricky bugs...