Fixed some bugs

the next commit will be the clone function ;)