Adding sign detection, more error handling and comments.