Add copyright notice and comments. Use proper return codes.