Handled edge case where resultion could be set to nan. Added option for resolution to be set by the user.