Fixed bug introduced during restructuring of code