bugs fixed

hopefully final version