Reduce visibility and remove unused code

Signed-off-by: Nico Rutishauser <nr@hotmail.ch>
Remove unneeded variables in the context

Signed-off-by: Nico Rutishauser <nr@hotmail.ch>
Minor improvements for sharing

Signed-off-by: Nico Rutishauser <nr@hotmail.ch>
Merge branch 'cleanup'