Solving bugs

Solving some bugs.