Use rustpkg

The patch mainly structures the code to use rustpkg. It also fixes some warnings.