some serious fixes