fix bug; add logging
fix client bug
refactor server code