some bug fixing, still really buggy