some new code bits, trying to make an app framework