fixed a few more bugs and typo