sheriff logic and some bug fixes