Reject function and some bug fixes