Added code extracted from existing app.