Fixed some bugs
Fixed fatal errors=)