Fixed some problems

Sixed some problems from the first version