fix initialization problems caused by bad order-of-operations