Cleanup code, add messagebox