Oh man I just noticed this function is completely bugged. When it checks if (align == ...) to validate the parameter, it should actually be checking if (newAlign == ). So... all of the checking actually is useless (worse than useless, because it looks like it's implemented and should work from a quick glance of the code).