Solutions to various stack overflow questions