Parts library refactoring and bugfixes

This commit orignally consisted of 8 patches
Un-squased commits are at https://github.com/hriesz/oregano
Merge pull request #69 from drahnr/parts

Parts library refactoring and bugfixes, a big thanks to hriesz