Code works on boot loader but not when directly programmed

The C startup code should do all that. Does the "upload using programmer" set fuses? if not, you'll need some other tool to do so, especially if the chip was previously used WITHO a bootloader.