Fix Apply Discard bug and fix all code
Merge pull request #2 from MiracleM4n/master

Fix *all* issues