add lots of implementation, first hopefully complete version