Fixed exits and bugs