Added PWL Stimulus and refactored some code