-fixed several bugs