initial if processing and small set of bug fixes