Most bugs fixed