better checks, cleanups