Various fixes, fixed when taking pruned branch, enchanced static function