Greatly improved door logic