moving declarations closer to their use
adding some preprocessor-proof assertions