misc bugs fixed (close to being done!)