Bugfixes and more streamlined build process

Signed-off-by: Knut Svangstu <knut@gmail.com>
Bugfix for missing variable

Signed-off-by: Knut Svangstu <knut@gmail.com>