Fixes as per request @simonlynen
Fixed libcvd conditionals and optimization