Implemented RFC3986 encoding of secrets
Fixed missing closing statements