made some cleanup from the old the implementation, still need more
cleanup though.