cleaned up pid config section to make it cleaner, added comments to explain various sections of code