Fixed stack bugs; sparse code working