Improve and simplify initializion of ports and their trigger levels.