Added size attribute and cleaner way of checking file extension.