some cleanup, added envelope-signal function