Added open operation.
Fixed some coding style errors and warnings.