improvements on rezn8d's changes