Don't directly use config variables.
Split layouts functions out into layouts.c
Replace useless local variable.