Fixed app crashes when using more layers or the FPS counter.
