almost all bugs fixed