Added misc module; fixed memory leaks; error handling for 'rules' file