Fix screenframe calculation and add debugging flag