weird buggy code problem

It's possible that the code is too big for the Arduino board - what size gets printed when you upload your sketch? Unfortunately, we don't get error messages when this happens. Arduino 0004 has a check if the sketch is too big, but it assumes the most recent bootloader version (which is 1 KB). If you have an older (2 KB) version of the bootloader, the environment might not realize that the code is too big, attempt to upload it, and not realize that it failed.

When did you get your board? If it's an old version, and you have access to an AVR-ISP or parallel port programmer, you might try burning the latest version of the bootloader (using the Tools | Burn Bootloader option). Otherwise, you can tell the Arduino environment the amount of space available for sketches by editing the upload.maximum_size variable in your preferences file (see: Arduino - Home for instructions on finding the file). Change 7168 to 6144, and the environment should correctly warn you when your sketch is too big.