Solved several bugs and typo, thanks bobim