Fixed a bug where remaining might be used in a way where it would go negative