finish sharing functionality, clean up code, add comments