Fixed compiler crash, simplified code