Simple code fixes

Some simple code changes and fixes. The only ones that will have an effect in the code logic are the ones related with the constants that have been changed to be a power of two.