Fixed resize bug and added comments