some fixes, will explain later