fix bug where first envelope value is always zero. also fix some other shit.