Cleaned up code and added a bean exception.