Fix some warnings in xsys

- Remove unused code
- Fix leak