Code rewritten to use KConfig for configuration