Fixin some bugs discovered