fixed ios 7 overlay bug; code reorganization