fix several issues (still WIP)