#307 first bunch of fixes, not finish yet