Some bugs fixed. There are more :(