some fixes (still buggy)
some fixes (still buggy)