Refactor KRL Program writer