custom.cpp: minor compilation fixes and cleanup