Added invitation support. Did some cleanup, more functions now return the connection object.