Fixed implementation bugs