Added permission handling. Added resize mechanism