Added basic validation and error handling

Change-Id: I1fa18ef7c74a68969e8a93b536628c4cd0cbcc71