Move application mngmt functionality to bb.runtime. Add app serialization.